﻿
#include "common_path.h"
#include "FileOperation.h"
#include <string.h>



#define PICTURE_PATH_NUMBER  100
#define PICTURE_PATH_SIZE    50



const uint8_t picturePath[PICTURE_PATH_NUMBER][PICTURE_PATH_SIZE] = {
	DTA_PATH_BGHOME,
	DTA_3X4,
	DTA_4X3,
	DTA_4X4,
	//DTA_PATH_BG4X4,
	//DTA_PATH_BGCONTROL,
	//DTA_PATH_BGNAVIGATE,
	//DTA_PATH_BGSETTING,
	//DTA_PATH_BG3X3,
	//DTA_PATH_BG4X4,
	//RETURN,
	//DTA_SWITCH_ON,
	//DTA_SWITCH_OFF,
	//DTA_PALETTE,
	//DTA_ROOM_LIVING,
	//DTA_ROOM_BED,
	//DTA_ROOM_KITCHEN,
	//DTA_ROOM_WASH,
	//DTA_ROOM_STUDY,
	//DTA_CON_ADD,
	//DTA_CON_DEL,
	//DTA_CON_AUTO_ON,
	//DTA_CON_AUTO_OFF,
	//DTA_CON_COLD_ON,
	//DTA_CON_COLD_OFF,
	//DTA_CON_HEAT_ON,
	//DTA_CON_HEAT_OFF,
	//DTA_CON_SWITCH_ON,
	//DTA_CON_SWITCH_OFF,
	//DTA_CON_VENTIL_ON,
	//DTA_CON_VENTIL_OFF,
	//DTA_CON_WET_ON,
	//DTA_CON_WET_OFF,
	//DTA_TEMP_SET,
	//DTA_HOME_ALARM,
	//DTA_HOME_SET,
	//DTA_FUN_CONDITION_ON,
	//DTA_FUN_CONDITION_OFF,
	//DTA_FUN_CURTAIN_ON,
	//DTA_FUN_CURTAIN_OFF,
	//DTA_FUN_LIGHT_ON,
	//DTA_FUN_LIGHT_OFF,
	//DTA_FUN_FLOORHEAT_ON,
	//DTA_FUN_FLOORHEAT_ON,
	//DTA_FUN_MUSIC_ON,
	//DTA_FUN_MUSIC_OFF,
	//DTA_MODE_BACKHOME_ON,
	//DTA_MODE_BACKHOME_OFF,
	//DTA_MODE_AWAYHOME_ON,
	//DTA_MODE_AWAYHOME_OFF,
	//DTA_MODE_COFFEE_ON,
	//DTA_MODE_COFFEE_OFF,
	//DTA_MODE_MEETING_ON,
	//DTA_MODE_MEETING_OFF,
	//DTA_MODE_ONWORK_ON,
	//DTA_MODE_ONWORK_OFF,
	//DTA_MODE_LEISURE_ON,
	//DTA_MODE_LEISURE_OFF,
	//DTA_MODE_MEDIA_ON,
	//DTA_MODE_MEDIA_OFF,
	//DTA_CURTAIN_OPEN,
	//DTA_CURTAIN_CLOSE,
	//DTA_CURTAIN_CONTINUE,
	//DTA_CURTAIN_PAUSE,
	//DTA_MUSIC_RANDOM,                 
	//DTA_MUSIC_CIRCULATE,                
	//DTA_MUSIC_NEXT,                
	//DTA_MUSIC_PRE,               
	//DTA_MUSIC_VOLUMEUP,         
	//DTA_MUSIC_VOLUMEDOWN,
	//DTA_SET_UPDATE,
	//DTA_SET_LIGHT,
	//DTA_SET_LANGUAGE,
	//DTA_SET_LOCK,
	//DTA_SET_SETLOCK,
};

static GUI_HMEM pictureHmem[PICTURE_PATH_NUMBER];





uint8_t InitPicture(void)
{
	uint32_t size, count = 0;
	uint8_t *pBuffer;
	int8_t  ret = 0;
	GUI_BITMAP      bitMap;
	GUI_LOGPALETTE  palette;
	GUI_HMEM hMem;
	GUI_MEMDEV_Handle hMemdev;


	memset(pictureHmem, 0, sizeof(pictureHmem));


	for ( ; count < PICTURE_PATH_NUMBER; count++)
	{
		pBuffer = GetPictureData(picturePath[count], &size, &hMem);

		if (pBuffer != NULL)
		{
			ret = !GUI_CreateBitmapFromStream(&bitMap, &palette, pBuffer);
			hMemdev = GUI_MEMDEV_CreateEx(0, 0, bitMap.XSize, bitMap.YSize, GUI_MEMDEV_HASTRANS);

			if (ret == 1 && hMemdev > 0)
			{
				GUI_MEMDEV_Select(hMemdev);
				GUI_Clear();
				GUI_DrawBitmap(&bitMap, 0, 0);
				GUI_MEMDEV_Select(0);
				pictureHmem[count] = hMemdev;

			}
			else
				GUI_MEMDEV_Delete(hMemdev);

			GUI_ALLOC_Free(hMem);
		}
	}
}


GUI_HMEM GetPicturePathHmem(uint32_t pathIndex)
{
	GUI_HMEM hMem = 0;

	if (pathIndex < PICTURE_PATH_NUMBER)
		hMem = pictureHmem[pathIndex];

	return hMem;
}




